<template>
  <div class="app-container">
    <query></query>

    <el-table
      :data="employeeData"
      border
      fit
      highlight-current-row
      style="width: 100%"
      @sort-change="sortChange"
    >
      <el-table-column
        :label="employeeRemark.id"
        prop="id"
        sortable="custom"
        align="center"
        width="80"
        :class-name="getSortClass('id')"
      >
        <template #default="{ row }">
          <span>{{ row.userVo.id }}</span>
        </template>
      </el-table-column>

      <el-table-column
        :label="employeeRemark.username"
        width="120px"
        align="center"
      >
        <template #default="{ row }">
          <span>{{ row.userVo.username }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="employeeRemark.phoneNumber" min-width="150px">
        <template #default="{ row }">
          <span class="link-type" @click="handleUpdate()">{{
            row.userVo.phoneNumber
          }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="userVo.sex" :label="employeeRemark.sex" width="50">
      </el-table-column>
      <el-table-column prop="userVo.age" :label="employeeRemark.age" width="50">
      </el-table-column>
      <el-table-column prop="totalMoney" :label="employeeRemark.totalMoney" width="120">
      </el-table-column>
      <el-table-column prop="paidMoney" :label="employeeRemark.paidMoney" width="120">
      </el-table-column>
      <el-table-column :label="employeeRemark.status" min-width="150px">
        <template #default="{ row }">
          <el-tag>{{ row.userVo.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        :label="employeeRemark.createdTime"
        width="200"
      >
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.userVo.createdTime }}</span>
        </template>
      </el-table-column>
      <el-table-column
        :label="employeeRemark.operation"
        align="center"
        width="230"
        class-name="fixed-width"
      >
        <template #default="{ row }">
          <el-button type="primary" size="mini" @click="handleSeekInfo()">
            {{ employeeRemark.seek }}
          </el-button>
          <el-button size="mini" type="danger" @click="handleSeekInfo()">
            {{ employeeRemark.danger }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="employeeRemark.total"
      v-show="employeeRemark.total > 0"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="employeeRemark.currentPage"
      :page-sizes="[10, 20, 50, 100]"
      layout="total, sizes, prev, pager, next, jumper"
    />
  </div>
</template>

<script>
import query from "./query/index.vue";

export default {
  components: {
    query,
  },
  data() {
    return {
      employeeRemark: {
        id: "序号",
        username: "姓名",
        phoneNumber: "电话号码",
        sex: "性别",
        age: "年龄",
        status: '状态',
        totalMoney: '贷款总额',
        paidMoney: '已还贷款',
        createdTime:"创建时间",
        operation: "操作",
        seek: "查看信息",
        edit: "编辑",
        danger: "删除",
        total: "10",
        currentPage: "1",
      },
      employeeData: [],
    };
  },
  created() {
    this.getEmployeeData();
  },
  methods: {
    getEmployeeData() {
      this.$store
        .dispatch("request/get", "/user/list/loan")
        .then((data) => {
          this.employeeData = data;
        });
    },
    getSortClass(key) {
      console.log(key + "***");
    },
    sortChange(data) {
      const { prop, order } = data;
      if (prop === "id") {
        dataMap.sortByID(order);
      }
    },
    handleSeekInfo() {
      this.dialogueRemark.isVisible = true;
    },
    updateData() {},
    handleDelete() {},
    handleCurrentChange(page) {
      console.log(page);
    },
    handleSizeChange(val) {
      console.log(val);
    },
    handleAdd() {
      this.dialogueRemark.isVisible = true;
    },
  },
};
</script>